﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace SimpleRPC.Handler
{
    public class LengthFieldEncoder
    {
        public void Encode(byte[] buffer, out byte[] output)
        {
            if (buffer == null)
            {
                output = new byte[0];
            }
            output = new byte[2 + buffer.Length];
            Array.Copy(BitConverter.GetBytes((ushort)buffer.Length), output, 2);
            Array.Copy(buffer, 0, output, 2, buffer.Length);
        }
    }
}
